//
//  RBDZMEViewController.m
//  rubaoduanzi
//
//  Created by 李云飞 on 16/9/14.
//  Copyright © 2016年 liyunfei. All rights reserved.
//

#import "RBDZMEViewController.h"
#import "RBDZLoginTableViewCell.h"
#import "RBDZSectondTableViewCell.h"
#import "RBDZButton.h"
@interface RBDZMEViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
//保存第三组表格的文字
@property(nonatomic,strong)NSArray *thirdText;
//保存第四组表格的图片
@property(nonatomic,strong)NSArray *thirdImg;
//保存第四组表格的文字
@property(nonatomic,strong)NSArray *fourText;
//保存第四组表格的图片
@property(nonatomic,strong)NSArray *fourImg;

@end

@implementation RBDZMEViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView.delegate=self;
    self.tableView.dataSource=self;
    self.tableView.contentInset=UIEdgeInsetsMake(-35, 0, 0, 0);
    self.thirdText=@[@"我的消息(0)",@"我的投稿(0)",@"我的收藏(0)",@"我的吐槽(0)"];
    self.fourText=@[@"我关注的人(0)",@"关注我的人(0)"];
    self.navigationItem.title=@"我";
    self.thirdImg=@[@"list_wdxx",@"list_wdtg",@"list_wdsc",@"list_wdpl"];
    self.fourImg=@[@"list_wgzdr",@"list_gzwdr"];
    [self addItem];
}
#pragma mark 返回多少组
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 4;
}
#pragma mark 返回每组多少行
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section==0) {
        return 1;
    }else if(section==1){
        return 1;
    }else if (section==2){
        return self.thirdText.count;
    }else{
        return self.fourText.count;
    }
}
#pragma mark 返回每行的内容
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section==0) {
        RBDZLoginTableViewCell *cell=[RBDZLoginTableViewCell loginTableViewCell];
        return cell;
    }else if (indexPath.section==1){
        RBDZSectondTableViewCell *cell=[RBDZSectondTableViewCell sectondTableViewCell];
        return cell;
    }else if (indexPath.section==2){
        static NSString *ID=@"cell1";
        UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:ID];
        if (cell==nil) {
            cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        }
        cell.imageView.image=[UIImage imageNamed:self.thirdImg[indexPath.row]];
        cell.textLabel.text=self.thirdText[indexPath.row];
        return cell;
    }else{
        static NSString *ID=@"cell2";
        UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:ID];
        if (cell==nil) {
            cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        }
        cell.imageView.image=[UIImage imageNamed:self.fourImg[indexPath.row]];
        cell.textLabel.text=self.fourText[indexPath.row];
        cell.textLabel.font=[UIFont systemFontOfSize:20];
        return cell;
    }
}
#pragma mark 设置组头高度
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0;
}
#pragma mark 返回每行的高度
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section==0&&indexPath.row==0) {
        return 180;
    }else if(indexPath.section==1&&indexPath.row==0){
        return 100;
    }else{
        return 44;
    }
}
#pragma mark 添加按钮
-(void)addItem{
    UIButton *buttonL=[UIButton buttonWithType:UIButtonTypeCustom];
    buttonL.contentEdgeInsets=UIEdgeInsetsMake(0, -10, 0, 0);
    self.navigationItem.leftBarButtonItem=[RBDZButton barButtonItemWith:buttonL andTarget:self action:@selector(goToBack) andImageName:@"nav_back" andHightlightImage:@"nav_back_pre"];
    UIButton *buttonR1=[UIButton buttonWithType:UIButtonTypeCustom];
    UIButton *buttonR2=[UIButton buttonWithType:UIButtonTypeCustom];
    buttonR2.contentEdgeInsets=UIEdgeInsetsMake(0, 10, 0, 0);
    UIBarButtonItem *itemR1=[RBDZButton barButtonItemWith:buttonR1 andTarget:self action:@selector(setting) andImageName:@"nav_sz" andHightlightImage:@"nav_sz_pre"];
    UIBarButtonItem *itemR2=[RBDZButton barButtonItemWith:buttonR2 andTarget:self action:@selector(contribute) andImageName:@"nav_fb" andHightlightImage:@"nav_fb_pre"];
    self.navigationItem.rightBarButtonItems=@[itemR2,itemR1];
}
#pragma mark 返回
-(void)goToBack{
    [self.navigationController popViewControllerAnimated:YES];
}
#pragma mark 设置
-(void)setting{

}
#pragma mark 投稿
-(void)contribute{

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
